package org.example.thread.threadException.example;

import lombok.SneakyThrows;

/**
 * @Auther:Liu
 * @Testname:Product
 * @Date:2025/8/14 15:25
 */
public class Product implements Runnable {

    private Broker broker;

    public Product(Broker broker) {
        this.broker = broker;
    }

    @SneakyThrows
    public void run() {
        for (int i = 0; i < 20; i++) {
            Goods goods = new Goods();
            goods.setId(i+1);
            System.out.println("生产了"+goods);
            broker.purchase(goods);
            Thread.sleep(1000);
        }
    }
}
